package com.easy.life.controller;

import com.easy.life.common.R;
import com.easy.life.po.RoomInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.easy.life.service.RoomService;

import java.math.BigDecimal;


/**
 * 
 *
 * @author xuhbin
 * @email a2712136826@qq.com
 * @date 2021-02-27 14:51:15
 */
@RestController

public class RoomController {
    @Autowired
    private RoomService roomService;
    /**
     * 搜索房间
     */
    @PostMapping("/search/room")
    public R searchRoom(@RequestParam String city,@RequestParam Integer type,@RequestParam Long userId){
        return roomService.searchRoom(city,type,userId);
    }
    /**
     * 用户发布房间
     */
    @PostMapping("/publish/room")
    public R publishRoom(@ModelAttribute RoomInfo roomInfo){
        return roomService.publishRoom(roomInfo);
    }
    /**
     * 用户个人房源的查找
     */
    @GetMapping("/search/room/byUser/{id}")
    public R searchRoomByUser(@PathVariable("id") Long id){
        return roomService.searchRoomByUser(id);
    }
    /**
     * 推荐房间
     */
    @PostMapping("/recommend/room")
    public R recommendRoom(@RequestParam String location, @RequestParam Integer pageNum,@RequestParam Integer pageSize,
                           @RequestParam Long userId){
        return roomService.recommendRoom(location,pageNum,pageSize,userId);
    }

    @PostMapping("/setRoom/price")
    public R setRoomPrice(Long id, BigDecimal price){
        return roomService.setPriceById(id,price);
    }


}
